<template>
  <div>
    <van-nav-bar
      title="手机注册"
      left-text="返回"
      right-text="去登录"
      nav-bar-text-color="@white"
      left-arrow
      @click-left="onClickLeft"
       @click-right="onClickRight"
    />
    <!-- 手机注册界面 -->
    <div class="login-mb">  
      <div class="inner">
        <img src="../../assets/images/pic/logo/orange.png" alt="" />

        <div class="form" action="../index.html">
          <div class="nickName">
            <input
              type="text"
              placeholder="昵称"
              pattern="[0-9]{1,4}"
              required
              v-model="user.nickname"
            />
          </div>
          <input
            type="tel"
            placeholder="手机号"
            pattern="^1[3,5,9,8,6][0-9]{9}$"
            required
            v-model="user.phone"
          />
          <div class="yzm">
            <input
              type="text"
              placeholder="密码"
              pattern="[0-9]{1,4}"
              required
              v-model="user.password"
            />
          </div>
          <input type="submit" name="" id="" value="注  册" @click="reg" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getReg } from "../../request/api";
export default {
  data() {
    return {
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    reg() {
      if (this.user.phone !== "") {
        getReg(this.user).then((res) => {
          if (res.code == 200) {
            this.$toast.success("注册成功");
            this.$router.push("/login");
          } else {
            this.$toast.fail("注册失败");
          }
        });
      }
    },
    onClickLeft() {
      this.$toast.success("返回到上一级");
      this.$router.back();
    },
     onClickRight() {
      this.$toast.success("进入到登录页面");
      this.$router.push("/login")
    },
  },
  mounted(){
     document.title=this.$route.meta.title
  }
};
</script>

<style scoped>
/* * 顶部返回字体样式  */
/deep/.van-nav-bar {
  background: #ff6040;
}
/deep/ .van-nav-bar__title {
  font-size: 0.12rem;
  color: #fff;
}
/deep/ .van-nav-bar__title {
  font-size: 0.18rem;
  font-weight: bold;
  color: #fff;
}
/deep/ .van-nav-bar__text {
  color: #fff;
}
/deep/ .van-nav-bar .van-icon {
  font-size: 0.12rem;
  color: #fff;
}

/deep/ [class*="van-hairline"]::after {
  border: none;
}
/deep/ .van-nav-bar__content {
  height: 49px;
}
</style>